<?php
namespace Admin\Controller;
//门店地图维护
session_start();

use Common\Controller\AdminbaseController;

class MapController extends AdminbaseController{

	// 列表
	public function storemap(){
//        session('map',null);
	    if(!empty($id = I('get.id',0,'intval'))){

        }
        if(!empty(session('map'))){
            $map = session('map');
            $this->assign('map',$map);
        }

		$this->display();
	}

	// 添加提交
	public function add_post(){
		if(IS_POST){
		    $date = $_POST;
            $date['id'] = time();
            $map = 'map'.$date['id'];
            $_SESSION['map']["$map"] = $date;
            $success = array('id'=>$date['id'],'name'=>$date['map_name']);
            $this->ajaxReturn($success);
		}
	}

	// 编辑
	public function edit(){
	    $id = I('post.id',0,'intval');
	    $key = 'map'.$id;
        $map = $_SESSION['map'][$key];
        $this->ajaxReturn($map);
	}

	// 编辑提交
	public function edit_post(){
		if (IS_POST) {
            $date = $_POST;
            $map = 'map'.$date['id'];
            $_SESSION['map']["$map"] = $date;
            $success = array('id'=>$date['id'],'name'=>$date['map_name']);
            $this->ajaxReturn($success);
//            echo "<pre>";
//            print_r($_POST);
		}
	}

	// 删除
	public function delete(){
	    $id = I('get.id',0,'intval');
		if ($this->sms_model->delete($id)!==false) {
			$this->success("删除成功！");
		} else {
			$this->error("删除失败！");
		}
	}

}